﻿using B.S.Business.ErrorCode;
using B.S.Business.Write.API.Applications.Command.SupplierCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Business.Write.API.Controllers
{
    /// <summary>
    /// 供应商  写-API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagSupplierControllerController : ControllerBase
    {
        private readonly IMediator mediator;

        public ManagSupplierControllerController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 供应商添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<object>> SupplierAdd(SupplierAddCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 供应商删除处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<object>> SupplierDel([FromQuery] SupplierDelCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 供应商更新处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public Task<ApiResult<object>> SupplierUpd(SupplierUpdCommand command)
        {
            return mediator.Send(command);
        }
    }
}
